package gggameserver.exceptions;

import java.util.ArrayList;

public class GGProcessException extends GGException {

	private ArrayList cmdarray;
	private int exitValue;
	private String output;
	
	public GGProcessException(String message, ArrayList cmdarray, int exitValue, String output) {
		super(message);
		this.cmdarray = new ArrayList(cmdarray);
		this.exitValue = exitValue;
		this.output = output;
	}

	public String getCommand() {
		if (null == cmdarray) return null;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < cmdarray.size(); i++) {
			if (i > 0) sb.append(' ');
			sb.append('\"');
			sb.append(cmdarray.get(i));
			sb.append('\"');
		}
		return sb.toString();
	}
	
	public int getExitValue() {
		return exitValue;
	}

	public String getOutput() {
		return output;
	}
	
	@Override
	public String toString() {
		return super.toString() + "\ncommand = " + getCommand() + "\nexit_value = " 
			+ getExitValue() + "\noutput = \"" + getOutput() + "\"";
	}
	
}
